package com.jeebey.mybatis.dao;

import java.util.List;

import org.apache.ibatis.annotations.CacheNamespace;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.session.RowBounds;
import org.springframework.stereotype.Repository;

import com.jeebey.mybatis.bean.User;
import com.jeebey.mybatis.generic.GenericDao;
import com.jeebey.mybatis.query.Bounds;
import com.jeebey.mybatis.query.Criterion;
import com.jeebey.mybatis.query.Pagination;
import com.jeebey.mybatis.query.Paging;

@Repository
@CacheNamespace(implementation = org.mybatis.caches.ehcache.EhcacheCache.class, readWrite = true)
//@CacheNamespace(implementation = org.mybatis.caches.memcached.MemcachedCache.class, readWrite = true)
public interface UserDao extends GenericDao<User, Integer> {

	@Select("select * from t_user where gid=#{gid} or gid=#{gid}")
	public Pagination<User> selectUsersByGroupId(@Param("gid") String gid,@Param("paging") Paging<User> paging);

	@Select("select * from t_user where gid=#{gid} or name=#{name}")
	public Pagination<User> selectUsersByGroupId2(@Param("gid") String id,@Param("name") String name);

	@Select("select * from t_user")
	public List<User> selectUsersByCriterion(Criterion criterion);

	@Select("select * from t_user")
	public Pagination<User> selectUsersByPaging(@Param("criterion") Criterion criterion,@Param("paging") Paging<User> paging);

	@Select("select #[com.jeebey.mybatis.bean.User(name,ctime)] from t_user limit 1")
	public User selectUsersField();

	@Select("select count(1) from t_user")
	public Long selectUsersCountByCriterion(@Param("criterion") Criterion criterion);
	
	public boolean insertUser(User user);
	
	public List<User> selectUsersByList1(@Param("ids") List<Integer>ids);
	
	public List<User> selectUsersByList2(@Param("ids") List<Integer>ids,@Param("bounds") Bounds bounds);
	
	public List<User> selectUsersByList3(@Param("ids") List<Integer>ids,@Param("name") String name);

	public Pagination<User> selectUsersByList4(@Param("ids") List<Integer>ids,@Param("paging") Paging<User> paging);

	public Pagination<User> selectUsersByList5(@Param("ids") List<Integer>ids, RowBounds rowBounds);

}
